package com.wangyk.user.repository;

import com.wangyk.rabbitmqcommon.model.user.UserInfo;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

public interface UserRepository extends JpaRepository<UserInfo,String>
{
    /**
     * 查询所有的openId
     * */
    UserInfo findByOpenid(String openId);

    /**
     * 添加用户
     * */
    UserInfo save(UserInfo userInfo);


    /**
     * 查询多个用户
     * */
    @Query("SELECT u.id,u.create_time,u.openid,u.password,u.role,u.update_time,u.username FROM UserInfo u WHERE u.openid LIKE CONCAT('%',:openId,'%')")
    List<UserInfo> findLikeOpenid(@Param("openId") String openId);
}
